using System;
using UnityEngine;

[Serializable]
public class SaveInt
{
	[SerializeField]
	[HideInInspector]
	private int offset;

	[SerializeField]
	[HideInInspector]
	private int value;

	public SaveInt(int v)
	{
		value = (offset = 0);
		SetValue(v);
	}

	public int GetValue()
	{
		return value - offset;
	}

	public void SetValue(int v)
	{
		offset = UnityEngine.Random.Range(-1000, 1000);
		value = v + offset;
	}

	public override string ToString()
	{
		return GetValue().ToString();
	}

	public static implicit operator int(SaveInt value)
	{
		if (value == null)
		{
			return 0;
		}
		return value.GetValue();
	}

	public static implicit operator SaveInt(int value)
	{
		return new SaveInt(value);
	}
}
